package cn.edu.scau.cmi.liyetian.composite.safe;

import java.util.*;

//container
public class Team extends Organization{
	private String name;
	public Team() {
		
	}
	public Team(String name) {
		this.name = name;
	}
	public String getName() {
		return this.name;
		
	}

	List<Organization> list = new ArrayList<Organization>();
	
	public void addPerson(Person person) {
		list.add(person);
	}
	
	public void addTeam(Team team) {
		list.add(team);
	}
	
	@Override
	public String showMember() {
		String str = "";
		for(int i = 0;i < list.size();i++) {
			str = str + list.get(i).showMember();
		}
		return "("+str+")";
	}
	public Team findTeam(String str) {
		if(str.equals(this.getName())) {
			return this;
		}
		Team team = null;
		for(int i = 0;i < list.size();i++) {
			if(list.get(i).getClass().getName().equals("cn.edu.scau.cmi.liyetian.composite.safe.Team")) {
				if(((Team)list.get(i)).getName().equals(str)) {
					team = (Team)list.get(i);
					break;
				}
				else {
					team =  ((Team)list.get(i)).findTeam(str);
				}
			}
			else {
				
			}
		}
		return team;
	}
}
